function init_file(){
	if [[ -f $site_package ]]
	then
		first_file=${site_package##*/}
		site_package=${site_package%/minio}
	elif [[ -L $site_package ]]
	then
		site_package=$(ls -l $site_package | awk '{print $NF}')
		first_file=$(sudo ls -lt ${site_package} 2>/dev/null | sed -n '2p' | awk '{print $NF}')
	else
		first_file=$(sudo ls -lt ${site_package} 2>/dev/null | sed -n '2p' | awk '{print $NF}')
	fi
}
rm -rf res
echo "name,version,time">>res
modules=$(jps -l | grep -v Jps | awk '{print $2}')
for module in ${modules[@]}
do
	 folder_name=${module%/*}
	 parent_name=${folder_name##*/}
	 jar_name=${module##*/}
	 jar_name=${jar_name%%.jar}
	 ver_name=${jar_name##*-}
	 last_time=$(stat -c %Y $module)
	 formart_date=$(date '+%Y-%m-%d' -d @$last_time)
	 echo $parent_name,$ver_name,$formart_date >> res
done
####################thingsboard####################

last_time=$(sudo stat -c %Y /usr/share/thingsboard/bin/thingsboard.jar)
formart_date=$(date '+%Y-%m-%d' -d @$last_time)
version=$(echo $formart_date | sed 's/-//g')
echo yujingshan,$version,$formart_date >> res

####################thingsboard-gateway####################

pip_file=$(pip3 -V | awk '{print $4}')
site_package=${pip_file%/pip}
first_file=$(sudo ls -lt ${site_package}/thingsboard_gateway/connectors 2>/dev/null | sed -n '2p' | awk '{print $NF}')
if [[ ! -z $first_file ]]
then
	last_time=$(sudo stat -c %Y ${site_package}/thingsboard_gateway/connectors/$first_file)
	formart_date=$(date '+%Y-%m-%d' -d @$last_time)
	version=$(echo $formart_date | sed 's/-//g')
	echo chentangguan,$version,$formart_date >> res
fi

####################penglai####################

site_package="/opt/apexapp/web/dist"
init_file
if [[ ! -z $first_file ]]
then
	last_time=$(sudo stat -c %Y ${site_package}/$first_file)
	formart_date=$(date '+%Y-%m-%d' -d @$last_time)
	version=$(echo $formart_date | sed 's/-//g')
	echo penglai,$version,$formart_date >> res
fi

####################svg####################

site_package="/opt/apexapp/web/dist/svgeditor"
init_file
if [[ ! -z $first_file ]]
then
	last_time=$(sudo stat -c %Y ${site_package}/$first_file)
	formart_date=$(date '+%Y-%m-%d' -d @$last_time)
	version=$(echo $formart_date | sed 's/-//g')
	echo svg,$version,$formart_date >> res
fi

####################nacos####################

nacos_version=$(curl -s 'http://127.0.0.1:8848/nacos/v1/console/server/state' | jq -r '.version')
site_package="/usr/local/nacos"
init_file
if [[ ! -z $first_file ]]
then
	last_time=$(sudo stat -c %Y ${site_package}/$first_file)
	formart_date=$(date '+%Y-%m-%d' -d @$last_time)
	echo nacos,$nacos_version,$formart_date >> res
fi

####################redis####################

redis_version=$(/usr/local/redis/bin/redis-server -v | awk -F '[= ]+' '{print $4}')
site_package="/usr/local/redis"
init_file
if [[ ! -z $first_file ]]
then
	last_time=$(sudo stat -c %Y ${site_package}/$first_file)
	formart_date=$(date '+%Y-%m-%d' -d @$last_time)
	echo redis,$redis_version,$formart_date >> res
fi

####################mysql####################

mysql_version=$(mysql --version | awk '{print $3}')
site_package="/var/lib/mysql"
init_file
if [[ ! -z $first_file ]]
then
	last_time=$(sudo stat -c %Y ${site_package}/$first_file)
	formart_date=$(date '+%Y-%m-%d' -d @$last_time)
	echo mysql,$mysql_version,$formart_date >> res
fi

####################postgres####################

pg_version=$(psql --version | awk '{print $3}')
site_package="/var/lib/pgsql"
init_file
if [[ ! -z $first_file ]]
then
	last_time=$(sudo stat -c %Y ${site_package}/$first_file)
	formart_date=$(date '+%Y-%m-%d' -d @$last_time)
	echo postgres,$pg_version,$formart_date >> res
fi

####################taos####################

taos_version=$(taos --version | sed -n '1p' | awk -F '[ :]+' '{print $2}')
site_package="/var/lib/taos"
init_file
if [[ ! -z $first_file ]]
then
	last_time=$(sudo stat -c %Y ${site_package}/$first_file)
	formart_date=$(date '+%Y-%m-%d' -d @$last_time)
	echo taos,$taos_version,$formart_date >> res
fi

####################kafka####################

kafka_version=$(/usr/local/kafka/bin/kafka-topics.sh --version | sed -n '1p' | awk -F '[ :]+' '{print $1}')
site_package="/usr/local/kafka"
init_file
if [[ ! -z $first_file ]]
then
	last_time=$(sudo stat -c %Y ${site_package}/$first_file)
	formart_date=$(date '+%Y-%m-%d' -d @$last_time)
	echo kafka,$kafka_version,$formart_date >> res
fi

####################minio####################

minio_version=$(minio --version | sed -n '1p' | awk -F '[ :]+' '{print $3}')
site_package="/usr/local/bin/minio"
init_file
if [[ ! -z $first_file ]]
then
	last_time=$(sudo stat -c %Y ${site_package}/$first_file)
	formart_date=$(date '+%Y-%m-%d' -d @$last_time)
	echo minio,$minio_version,$formart_date >> res
fi
